function hms(s) {
	var h = Math.floor(s/3600);
	var m = Math.floor(s/60 - h*60);
	var s1 = Math.floor(s - h*3600 - m*60);
	var hh = h<10?'0'+h:''+h;
	var mm = m<10?'0'+m:''+m;
	var ss = s1<10?'0'+s1:''+s1;
	var hms1 = hh + mm + ss;
	return hms1;
}

var video = document.getElementsByTagName('video');
//console.log(videos);
if (video.length == 0) {
	var iframe = document.getElementsByTagName('iframe');	
	for (i=0; i<iframe.length; i++) {
		console.log(iframe[i].src);
		video = iframe[i].contentWindow.document.getElementsByTagName('video');//跨域阻止
		if (video.length != 0) {
			capture();
		}
	}
} else {
	capture();
}

function capture() {
	var canvas = document.createElement('canvas');
	//video[0].crossOrigin = '*';
	canvas.width = video[0].videoWidth;
	canvas.height = video[0].videoHeight;
	canvas.getContext('2d').drawImage(video[0], 0, 0, canvas.width, canvas.height);
	var link = document.createElement('a');
	var fn = document.title + hms(video[0].currentTime) + '_' + canvas.width + 'X' + canvas.height + '.jpg';
	console.log(fn);
	link.download = fn;
	link.href = canvas.toDataURL("image/jpeg", 1.0);
	link.click();
}